package org.groupg.practice;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class JsoupExample4 {
    public static void main(String[] args) {
        String html = "<div id='user' data-role='admin' data-id='123'>用户信息</div>";
        Document doc = Jsoup.parse(html);

        Element userDiv = doc.getElementById("user");
        String role = userDiv.attr("data-role"); // admin
        String id = userDiv.attr("data-id");     // 123
        String text = userDiv.text();            // 用户信息

        System.out.println("角色: " + role + ", ID: " + id + ", 文本: " + text);
    }
}
